<template>
  <div>
    <el-tabs v-model="tab" @tab-click="tabClick">
      <el-tab-pane label="企业文章库" name="0"></el-tab-pane>
    </el-tabs>
    <div style="padding: 0 10px 20px 10px">
      <el-table v-loading="loading" :data="tableList" style="width: 100%" :header-cell-style="headerCellStyle"
        :row-style="rowStyle" :cell-style="cellStyle" row-key="id">
        <el-table-column label="选择" width="55" align="center">
          <template scope="scope">
            <el-radio :label="scope.row.id" v-model="radioId">
              <span></span>
            </el-radio>
          </template>
        </el-table-column>
        <el-table-column type="index" width="55" align="center" label="序号" />
        <el-table-column label="标题" prop="materialName">
          <template slot-scope="{ row }">
            <div style="color: #082aff;cursor: pointer;" @click="toInfo(row)">
              {{ row.materialName }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="标签" prop="materialTag">
          <template slot-scope="{ row }">
            <tagGroupShowTable :tagGroup="row.tagVOS" />
            <!-- <div v-if="row.materialTag">
              <el-tag v-for="(item, index) in row.materialTag.split('；')" :key="index" size="mini">{{ item }}</el-tag>
            </div> -->
          </template>
        </el-table-column>
        <el-table-column label="创建人" prop="createBy"></el-table-column>
        <el-table-column label="审核人" prop="examineBy"></el-table-column>
      </el-table>
      <div class="page">
        <el-pagination background layout="prev, pager, next" :total="this.total" @current-change="change">
        </el-pagination>
      </div>
      <div class="btn-list">
        <el-button type="primary" @click="ok">确定</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import { articleList } from '@/api/article/group'
//
export default {
  name: "materialarticle",
  data() {
    return {
      radioId: "",
      loading: false,
      tab: '0',
      pageNum: 1,
      pageSize: 8,
      total: 0,
      tableList: [],
      headerCellStyle: {
        background: '#F8F8F8',
        color: '#1D1D1D',
        height: '40px',
        textAlign: 'center',
        borderLeft: 'none',
        borderRight: 'none',
      },
      rowStyle: {
        height: '40px',
        overflow: 'hidden',
        textOverflow: 'ellipsis',
        whiteSpace: 'nowrap',
      },
      cellStyle: {
        height: '40px',
        padding: '0',
        textAlign: 'center',
        borderLeft: 'none',
        borderRight: 'none',
        overflow: 'hidden',
        textOverflow: 'ellipsis',
        whiteSpace: 'nowrap',
      },
      selected: [],
    }
  },
  created() { },
  mounted() {
    this.getList(this.tab)
  },
  methods: {
    init() { },
    tabClick() {
      this.pageNum = 1
      this.getList(this.tab)
    },
    getList(levelType) {
      this.loading = true
      articleList({
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        mediaType: 4,
        categoryId: '',
        levelType,
        materialName: ''
      }).then(res => {
        this.loading = false
        if (res.code === 200) {
          const { rows, total } = res
          this.tableList = rows
          this.total1 = total
        }
      })
    },
    change(pageNum) {
      this.pageNum = pageNum
      this.getList(this.tab)
    },
    ok() {
      const temp = this.tableList.filter(item => item.id === this.radioId)
      this.$emit('confirm', temp)
    },
    toInfo(row) {
      this.$emit('view', {
        type: 'article',
        id: row.id
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.page {
  text-align: right;
}

.btn-list {
  margin-top: 10px;
  text-align: right;
}
</style>
